import 'dart:isolate';

import 'package:flutter/material.dart';
import 'package:kasax_demos2/entry/data_posts_test.dart';

class UserAccountServiceCenterDemo extends StatefulWidget {
  const UserAccountServiceCenterDemo({Key? key}) : super(key: key);

  @override
  _UserAccountServiceCenterDemoState createState() =>
      _UserAccountServiceCenterDemoState();
}

class _UserAccountServiceCenterDemoState
    extends State<UserAccountServiceCenterDemo> {
  double screenHeight = 0.0;
  double screenWidth = 0.0;

  @override
  Widget build(BuildContext context) {
    screenWidth = MediaQuery.of(context).size.width;
    screenHeight = MediaQuery.of(context).size.height;

    return Scaffold(
      appBar: AppBar(
        title: Text(""),
        backgroundColor: Colors.transparent,
        elevation: 0,
      ),
      extendBodyBehindAppBar: true,
      body: SingleChildScrollView(
        child: Container(
          color: Color.fromRGBO(68, 66, 86, 1.0),
          child: Column(
            children: [
              buildAccountHeader(),
              ListView.builder(
                shrinkWrap: true,
                physics: NeverScrollableScrollPhysics(),
                itemBuilder: (context, index) {
                  var inf = PostsDatas.TEST_POSTS[index];
                  return Container(
                    margin: EdgeInsets.only(left: 10, right: 10),
                    child: Card(
                      color: Colors.grey,
                      child: Opacity(
                        opacity: 0.9,
                        child: Container(
                          padding: EdgeInsets.only(left: 16, right: 16),
                          child: Padding(
                              padding: const EdgeInsets.all(8.0),
                              child: Text(
                                inf.description,
                                style: TextStyle(
                                    color: Colors.yellow,
                                    letterSpacing: 1,
                                    wordSpacing: 3),
                              )),
                        ),
                      ),
                    ),
                  );
                },
                itemCount: PostsDatas.TEST_POSTS.length,
              )
            ],
          ),
        ),
      ),
    );
  }

  Stack buildAccountHeader() {
    return Stack(
      overflow: Overflow.visible,
      children: [
        Container(
          height: screenHeight * 0.3,
          width: double.infinity,
          decoration: BoxDecoration(
              color: Colors.blueGrey,
              borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(30),
                  bottomRight: Radius.circular(30))),
          child: Padding(
            padding: const EdgeInsets.only(top: 100, left: 30),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  "刘祫",
                  style: TextStyle(
                      color: Colors.blue,
                      fontWeight: FontWeight.bold,
                      fontSize: 24),
                ),
                SizedBox(
                  height: 10,
                ),
                Text(
                  "134533221199",
                  style: TextStyle(
                      color: Colors.white,
                      fontSize: 15,
                      fontWeight: FontWeight.bold),
                ),
              ],
            ),
          ),
        ),
        Positioned(
            top: screenHeight * 0.22,
            left: 20,
            child: Opacity(
              opacity: 0.9,
              child: Container(
                width: screenWidth * 0.9,
                padding:
                    EdgeInsets.only(top: 30, bottom: 30, left: 16, right: 16),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(30),
                    boxShadow: [
                      BoxShadow(
                          offset: Offset(0.0, 0.6),
                          color: Colors.grey,
                          blurRadius: 6.0)
                    ]),
                child: Container(
                  padding: EdgeInsets.only(left: 16),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Column(
                        children: [
                          Text("收入"),
                          SizedBox(
                            height: 10,
                          ),
                          Divider(),
                          Text(
                            "RMB: 500.000",
                            style: TextStyle(
                                fontWeight: FontWeight.bold, fontSize: 18),
                          ),
                        ],
                      ),
                      Column(
                        children: [
                          Text("支出"),
                          SizedBox(
                            height: 10,
                          ),
                          Divider(),
                          Text("RMB: 260.000",
                              style: TextStyle(
                                  fontWeight: FontWeight.bold, fontSize: 18)),
                        ],
                      )
                    ],
                  ),
                ),
              ),
            ))
      ],
    );
  }
}
